function [FOC] = eqfind_complete(controls,pi1,w1,w2,y1vec,y2vec,yf,gamma,gammaf,relativesize,boundary,penalty)
%This function computes the cournot-walras equilibrium with a complete set
%of Arrow securities


a1=controls(1:2);%asset positions of Type 1
a2=-a1;%Back out from market clearing with a small fringe
af=controls(3:4);

pivec=[pi1,1-pi1];

cf=yf+af;

pricesAD=pivec.*(cf).^(-gammaf); %Prices

priceimpactAD=gammaf*pivec.*(cf).^(-gammaf-1);


c01=w1-sum(pricesAD.*a1); %Type 1 consumption within the period
c02=w2-sum(pricesAD.*a2); %Type 2 consumption within the period

c1prime=y1vec+a1; %Type 1: 1x2 vector of state-contingent updated wealth
c2prime=y2vec+a2; %Type 2: 1x2 vector of state-contingent updated wealth

    

%Compute state prices

Lambda1=(pivec.* c1prime.^-gamma)./(c01^(-gamma));
Lambda2=(pivec.* c2prime.^-gamma)./(c02^(-gamma));

FOC=[Lambda1-pricesAD-(relativesize)*priceimpactAD.*a1,Lambda2-pricesAD-(relativesize)*priceimpactAD.*a2];

if min(c1prime) <= 0 || min(c2prime) <= 0 || c01 <= 0 || c02 <= 0

FOC = (1 + penalty) * sqrt(FOC.^2);
    
end

end